<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .big {
            height: 200px;
            width: 200px;
            background-color: pink;
        }
        
        .small {
            height: 50px;
            width: 50px;
            background-color: red;
        }
    </style>
</head>

<body>
    <button onclick="fn()">点击创建一个盒子</button>
    <div class="big"></div>
</body>
<script>
    var big = document.querySelector('.big');
		// big.addEventListener()
		// big.attachEvent()
    function fn() {
        var small = document.createElement('div');
        small.classList.add("small");
        small.innerHTML = '小盒子'
        big.appendChild(small);
    }
</script>

</html>